-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
with_param #159
base: main
Are you sure you want to change the base?
with_param #159
Conversation
8891fb7
to
32382c9
Compare
edbd788
to
abf96dd
Compare
Aside from the simpler types, the following needs testing:
I'd maybe also not mix it with |
135598b
to
70aa220
Compare
So already found issue with basic tests. String Note once a string is contained it is expected to be quoted in params: ClickHouse/clickhouse-connect#159 |
5466a0e
to
19ba376
Compare
src/lib.rs
Outdated
@@ -160,6 +161,12 @@ impl Client { | |||
self | |||
} | |||
|
|||
pub fn with_param(self, name: &str, value: impl Serialize) -> Result<Self, String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of Client::with_param
? Parameters are specific for queries, not the whole client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, but if someone wants to share parameter between queries queries they can put it on the client
For example, in a multi tenant app, tenantid could be put as a parameter in the function creating client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the obscure outcomes you're thinking of? Better people use this than roll it themselves with options
This keeps things simple compared to https://github.com/citusdata/django-multitenant or https://github.com/citusdata/activerecord-multi-tenant tho those hook into ORM to inject predicates
We also need tests for And need to add some examples. |
src/query.rs
Outdated
@@ -195,6 +195,12 @@ impl Query { | |||
self.client.add_option(name, value); | |||
self | |||
} | |||
|
|||
pub fn with_param(self, name: &str, value: impl Serialize) -> Result<Self, String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method must be well documented. Also, we should specify the difference between param()
and bind()
(probably in a dedicated section on Query
and provide links to that section in docs of both methods).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added some docs, signature should somewhat communicate difference given ? is positional while server side parameters are key/value
2eaaa70
to
759a7e0
Compare
@loyd, I'd like to merge this one. WDYT? |
Small wrapper around
with_option
forimpl Serialize + Bind